using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using DAL;
using BUS;

public partial class Admin_NhanVienUpdate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }

    }
    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            tbNhanVien  nv = tbNhanVienBUS .GetByID(id);
            if (nv != null)
            {
                txt_manv .Text = nv.IDNhanVien.ToString();
                txt_tennv .Text = nv.TenNV ;
                txt_dc .Text = nv.DiaChi ;
                txt_dt .Text = nv.DienThoai ;
                txt_email .Text = nv.Email ;
                txt_tk .Text = nv.TaiKhoan ;
                txt_mk .Text = nv.MatKhau;
            }
        }
        catch
        {
            Response.Redirect("~/Admin/NhanVienList.aspx");
        }

    }
    protected void btnv_update_Click(object sender, EventArgs e)
    {
        tbNhanVien nv = new tbNhanVien();
        nv.IDNhanVien = int.Parse(txt_manv.Text);
        nv.TenNV = txt_tennv .Text;
        nv.DienThoai = txt_dt.Text;
        nv.DiaChi = txt_dc.Text;
        nv.Email = txt_email.Text;
        nv.TaiKhoan = txt_tk.Text;
        nv.MatKhau = txt_mk.Text;
        tbNhanVienBUS.Update(nv);
        Response.Redirect("~/Admin/NhanVienList.aspx");
    }
}
